package models;

import java.util.ArrayList;
import java.util.List;

import entities.AnalyticDataSource;
import entities.User;

import services.GoogleAnalytics;

public class AnalyticServiceModel {
	
	private User user;
	
	public AnalyticServiceModel(User user) {
		this.user = user;
	}
	
	public AnalyticDataSource getVisitPerMonth(String profileId) {
		AnalyticDataSource dataSource = new AnalyticDataSource();
		
		GoogleAnalytics analyticService = new GoogleAnalytics(user);
		
		String ids = "ga:" + profileId;
		String dimensions = "ga:date";
		String metrics = "ga:visits,ga:pageviews";
		String sort = "ga:date";
		int maxResults = 0;
		String startDate = "2012-06-01";
		String endDate = "2012-06-30";
		
		dataSource = analyticService.getDataFeed(ids, dimensions, metrics, startDate, endDate, maxResults, sort);
		
		return dataSource;
	}
	
	public AnalyticDataSource getVisitPerYear(String profileId) {
		AnalyticDataSource dataSource = new AnalyticDataSource();
		
		GoogleAnalytics analyticService = new GoogleAnalytics(user);
		
		String ids = "ga:" + profileId;
		String dimensions = "ga:month";
		String metrics = "ga:visits,ga:pageviews";
		String sort = "ga:month";
		int maxResults = 0;
		String startDate = "2012-01-01";
		String endDate = "2012-12-30";
		
		dataSource = analyticService.getDataFeed(ids, dimensions, metrics, startDate, endDate, maxResults, sort);
		
		return dataSource;
	}
	
	public AnalyticDataSource getVisitPerMonthByLocation(String profileId) {
		AnalyticDataSource dataSource = new AnalyticDataSource();
		
		GoogleAnalytics analyticService = new GoogleAnalytics(user);
		
		String ids = "ga:" + profileId;
		String dimensions = "ga:country";
		String metrics = "ga:visits,ga:percentNewVisits,ga:bounces,ga:avgTimeOnPage";
		String sort = "ga:visits";
		int maxResults = 0;
		String startDate = "2012-06-01";
		String endDate = "2012-06-30";
		
		dataSource = analyticService.getDataFeed(ids, dimensions, metrics, startDate, endDate, maxResults, sort);
		
		return dataSource;
	}
	
	public AnalyticDataSource getVisitPerYearByLocation(String profileId) {
		AnalyticDataSource dataSource = new AnalyticDataSource();
		
		GoogleAnalytics analyticService = new GoogleAnalytics(user);
		
		String ids = "ga:" + profileId;
		String dimensions = "ga:country";
		String metrics = "ga:visits,ga:percentNewVisits,ga:bounces,ga:avgTimeOnPage";
		String sort = "ga:visits";
		int maxResults = 0;
		String startDate = "2012-01-01";
		String endDate = "2012-12-30";
		
		dataSource = analyticService.getDataFeed(ids, dimensions, metrics, startDate, endDate, maxResults, sort);
		
		return dataSource;
	}
}
